package com.uniledger.exchange.login.fragment;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;

import com.uniledger.commonlib.util.KeyboardPopHelper;
import com.uniledger.exchange.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 名字填写
 */
public class SignUpOneFragment extends SignUpFragment {

    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";


    private String mParam1;
    private String mParam2;

    @BindView(R.id.edit_first_name)
    EditText firstName;

    @BindView(R.id.edit_last_name)
    EditText lastName;


    public SignUpOneFragment() {
        // Required empty public constructor
    }

    public static SignUpOneFragment newInstance(String param1, String param2) {
        SignUpOneFragment fragment = new SignUpOneFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_sign_up_one, container, false);
        ButterKnife.bind(this, view);

        KeyboardPopHelper.instance(getActivity())
                .bindEditText(firstName,lastName)              // 绑定目标edittext
                .bindRootView(view.findViewById(R.id.rootLayout))        // 绑定页面根布局
                .setMonitorFocusSizeChanged(true)                   // 是否监控focusView高度的变化
                .setBottomMargin(10)                                // focusView的bottom
                .setOffset(-100)                                    // 固定模式下的偏移
                .monitor();

        return view;
    }


    @Override
    public void onClick(View v) {
        String first = firstName.getText().toString();
        String last = lastName.getText().toString();
        if (!TextUtils.isEmpty(first) && !TextUtils.isEmpty(last)) {
            upListener.getName(first, last);
        } else {
            //TODO 提示信息
        }
    }
}
